<?php if(!defined('BASEPATH')) exit ('No direct script access allowed');
class C_managebank extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->model('m_managebank');
	}
	function index(){
		$this->load->view('admin/pages/v_managebank');
	}
	function action(){
		$action = isset($_POST['action']) ? @$_POST['action'] : @$_GET['action'];
		switch($action){
			case "bank_add":
				$this->bank_add();
			break;
			case "bank_edit":
				$this->bank_edit();
			break;
			case "bank_delete":
				$this->bank_delete();
			break;
			default:
				echo "{ failure : true }";
			break;
		}
	}
	function data_bank(){
		$key = isset($_GET['key']) ? @$_GET['key'] : @$_POST['key'];
		$result = $this->m_managebank->data_bank($key);
		echo "{\"results\":" .$result. "}";
	}
	function bank_add(){
		$bank_nama = trim(@$_POST['bank_nama']);
		$bank_norek = trim(@$_POST['bank_norek']);
		$result = $this->m_managebank->bank_add($bank_nama,$bank_norek);
		echo $result;
	}
	function bank_edit(){
		$bank_id = trim(@$_POST['bank_id']);
		$bank_nama = trim(@$_POST['bank_nama']);
		$bank_norek = trim(@$_POST['bank_norek']);
		$result = $this->m_managebank->bank_edit($bank_id,$bank_nama,$bank_norek);
		echo $result;
	}
	function bank_delete(){
		$bank_id = trim(@$_POST['bank_id']);
		$result = $this->m_managebank->bank_delete($bank_id);
		echo $result;
	}
}
?>